﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath }"/>
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
    <meta charset="utf-8" />
    <title>固定资产管理系统</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1.0" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <meta name="MobileOptimized" content="320">
    <!-- BEGIN GLOBAL MANDATORY STYLES -->
    <link href="${ctx}/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
    <!-- END GLOBAL MANDATORY STYLES -->
    <!-- BEGIN THEME STYLES -->
    <link href="${ctx}/assets/css/style-metronic.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/assets/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/assets/css/plugins.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/assets/css/pages/tasks.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/assets/css/themes/light.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/assets/css/custom.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/css/custom.css" rel="stylesheet" type="text/css"/>

    <link rel="stylesheet" type="text/css" href="${ctx}/assets/plugins/select2/select2_metro.css" />
    <link rel="stylesheet" href="${ctx}/assets/plugins/data-tables/DT_bootstrap.css" />

    <link href="${ctx}/assets/plugins/bootstrap-modal/css/bootstrap-modal-bs3patch.css" rel="stylesheet" type="text/css"/>
    <link href="${ctx}/assets/plugins/bootstrap-modal/css/bootstrap-modal.css" rel="stylesheet" type="text/css"/>
    <!-- END THEME STYLES -->
    <link rel="shortcut icon" href="favicon.ico" />
    <style type="text/css">
        .page-content{
            min-height:900px;
        }
        .checked-text{height:34px;line-height:34px;font-size:16px;}
    </style>
</head>
<body class="page-header-fixed">
<!-- BEGIN HEADER -->
<%@include file="../include/header.jsp" %>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <!-- BEGIN SIDEBAR -->
    <%@include file="../include/sidebar.jsp" %>
    <!-- END SIDEBAR -->
    <!-- BEGIN PAGE -->
    <div class="page-content">
        <div class="row">
            <div class="col-md-12">
                <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                <h3 class="page-title">
                    资产报废流程
                </h3>

                <!-- END PAGE TITLE & BREADCRUMB-->
            </div>
        </div>
        <!-- END PAGE HEADER-->
        <!-- BEGIN PAGE CONTENT-->
        <div class="row">
            <div class="col-md-12">
                <!-- BEGIN TAB PORTLET-->
                <div class="portlet box green tabbable">
                    <div class="portlet-title">
                        <div class="caption"><i class="fa fa-reorder"></i>资产报废待办</div>
                    </div>
                    <div class="portlet-body">
                        <div class=" portlet-tabs">
                            <ul class="nav nav-tabs">
                                <c:if test="${!empty bfxgbmspList}"><li><a href="#portlet_tab0" data-toggle="tab" id="bfxgbmspTab">归口部门审批</a></li></c:if>
                                <shiro:hasRole name="低值管理员"><c:if test="${!empty yiShenQingBaoFeiList}"><li><a href="#portlet_tab7" data-toggle="tab">管理员审批</a></li></c:if></shiro:hasRole>
                                <shiro:hasRole name="部门负责人"><c:if test="${!empty baoFeiBMList}"><li><a href="#portlet_tab1" data-toggle="tab" id="bmspTab">部门审批</a></li></c:if></shiro:hasRole>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane" id="portlet_tab7">
                                    <div class="portlet-body">
                                        <div class="table-scrollable">
                                            <table class="table table-striped table-bordered table-hover">
                                                <thead>
                                                <tr>
                                                    <th>资产编号</th>
                                                    <th>物资名称</th>
                                                    <th>品牌</th>
                                                    <th>开始使用日期</th>
                                                    <th>报废类型</th>
                                                    <th>报废原因</th>
                                                    <th>申请部门</th>
                                                    <th>申请人</th>
                                                    <th>查看</th>
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody id="yiShenQingBaoFeiList_data">
                                                <c:forEach items="${yiShenQingBaoFeiList }" var="u">
                                                    <tr>
                                                        <td>${u.wuZi.ziChanBH }</td>
                                                        <td>${u.wuZi.wuZiMC }</td>
                                                        <td>${u.wuZi.pinPai }</td>
                                                        <td><fmt:formatDate value="${u.wuZi.kaiShiJiTiRQ }" pattern="yyyy-MM-dd"/></td>
                                                        <td>
                                                            <c:choose>
                                                                <c:when test="${u.baoFeiLX==1 }">
                                                                    到年限
                                                                </c:when>
                                                                <c:when test="${u.baoFeiLX==2 }">
                                                                    损坏不可用
                                                                </c:when>
                                                            </c:choose>
                                                        </td>
                                                        <td>${u.baoFeiYY }</td>
                                                        <td>${u.user.dep.depName }</td>
                                                        <td>${u.user.name }</td>
                                                        <td>
                                                            <a href="${ctx }/wuzi/wuZiDetail.do?id=${u.wuZi.id}" target="_blank" class="btn default btn-xs green-stripe">物资详情</a>&nbsp;&nbsp;
                                                            <a href="${ctx }/wuzi/baoFeiDetail.do?id=${u.id}" target="_blank" class="btn default btn-xs green-stripe">流程详情</a>
                                                        </td>
                                                        <td>
                                                            <a class="btn default btn-xs yellow-stripe" href="javascript:jiXuSP('${u.id}');">报废审批</a>
                                                            <a class="btn default btn-xs yellow-stripe" href="javascript:zhiJieBF('${u.id}');">直接报废</a>
                                                        </td>
                                                    </tr>
                                                </c:forEach>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane" id="portlet_tab0">
                                    <div class="portlet-body">
                                        <form method="POST" id="baoFeiHQForm">
                                            <div class="row" style="margin-bottom:10px;">
                                                <div class="col-md-6">
                                                    <span class="checked-text"></span>
                                                </div>
                                                <div class="col-md-6">
                                                    <div style="text-align:right;">
                                                        <a class="btn blue" id="bfhqPiSubmit"><i class="fa fa-search"></i>&nbsp;&nbsp;批量同意</a>
                                                        <a class="btn red" id="bfhqBHPL"><i class="fa fa-edit"></i>&nbsp;&nbsp;批量驳回</a>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="table-scrollable">
                                                <table class="table table-striped table-bordered table-hover">
                                                    <thead>
                                                    <tr>
                                                        <th><input type="checkbox" id="bfhqSelectAll"></th>
                                                        <th>资产编号</th>
                                                        <th>物资名称</th>
                                                        <th>品牌</th>
                                                        <th>规格型号</th>
                                                        <th>产品序列号</th>
                                                        <th>报废类型</th>
                                                        <th>报废原因</th>
                                                        <th>查看</th>
                                                        <th>操作</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody id="bfxgbmspData">
                                                    </tbody>
                                                </table>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                                <div class="tab-pane" id="portlet_tab1">
                                    <div class="portlet-body">
                                        <form method="POST" id="bmbaoFeiForm">
                                            <div class="row" style="margin-bottom:10px;">
                                                <div class="col-md-6">
                                                    <span class="checked-text"></span>
                                                </div>
                                                <div class="col-md-6">
                                                    <div style="text-align:right;">
                                                        <a class="btn blue" id="bmPiSubmit"><i class="fa fa-search"></i>&nbsp;&nbsp;批量同意</a>&nbsp;&nbsp;
                                                        <a class="btn red" id="bmspBHPL"><i class="fa fa-search"></i>&nbsp;&nbsp;批量驳回</a>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="table-scrollable">
                                                <table class="table table-striped table-bordered table-hover">
                                                    <thead>
                                                    <tr>
                                                        <th><input type="checkbox" id="bmSelectAll"></th>
                                                        <th>申请日期</th>
                                                        <th>资产编号</th>
                                                        <th>物资名称</th>
                                                        <th>产品序列号</th>
                                                        <th>报废类型</th>
                                                        <th>报废原因</th>
                                                        <th>查看</th>
                                                        <th>操作</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody id="bmsp">
                                                    </tbody>
                                                </table>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- END PAGE CONTAINER-->
    </div>
    <!-- END PAGE -->
</div>
<!-- END CONTAINER -->
<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
    <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0 pluginspage="install_lodop32.exe"></embed>
</object>
<!-- BEGIN FOOTER -->
<%@include file="../include/footer.jsp" %>
<!-- END FOOTER -->
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
	<script src="${ctx}/assets/plugins/respond.min.js"></script>
	<script src="${ctx}/assets/plugins/excanvas.min.js"></script>
	<![endif]-->
<script src="${ctx}/assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="${ctx}/assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<!-- IMPORTANT! Load jquery-ui-1.10.3.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
<script src="${ctx}/assets/plugins/jquery-ui/jquery-ui-1.10.3.custom.min.js" type="text/javascript"></script>
<script src="${ctx}/assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="${ctx}/assets/plugins/bootstrap-hover-dropdown/twitter-bootstrap-hover-dropdown.min.js" type="text/javascript" ></script>
<script src="${ctx}/assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="${ctx}/assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="${ctx}/assets/plugins/jquery.cookie.min.js" type="text/javascript"></script>
<script src="${ctx}/assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript" ></script>
<!-- END CORE PLUGINS -->

<!-- IMPORTANT! fullcalendar depends on jquery-ui-1.10.3.custom.min.js for drag & drop support -->
<script src="${ctx}/assets/plugins/fullcalendar/fullcalendar/fullcalendar.min.js" type="text/javascript"></script>
<script src="${ctx}/assets/plugins/jquery-easy-pie-chart/jquery.easy-pie-chart.js" type="text/javascript"></script>
<script src="${ctx}/assets/plugins/jquery.sparkline.min.js" type="text/javascript"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="${ctx}/assets/scripts/app.js" type="text/javascript"></script>
<script src="${ctx}/assets/scripts/index.js" type="text/javascript"></script>
<script src="${ctx}/assets/scripts/tasks.js" type="text/javascript"></script>

<script type="text/javascript" src="${ctx}/assets/plugins/select2/select2.min.js"></script>
<script src="${ctx}/assets/plugins/bootstrap-modal/js/bootstrap-modalmanager.js" type="text/javascript" ></script>
<script src="${ctx}/assets/plugins/bootstrap-modal/js/bootstrap-modal.js" type="text/javascript" ></script>
<script src="${ctx}/assets/scripts/table-advanced.js?t=202004022058"></script>
<script type="text/javascript" src="${ctx }/lodop/LodopFuncs.js"></script>
<!-- END PAGE LEVEL SCRIPTS -->
<script>
    var LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
    jQuery(document).ready(function() {
        App.init(); // initlayout and core plugins
        $('#A').addClass("active");
        $('#A5').addClass('active');
        TableAdvanced.init();

        $('#bmPiSubmit').click(function(){
            var data = $("#bmbaoFeiForm").parseForm();
            if (!data.baoFeiId) {
                alert('未选择审批内容');
                return;
            }
            data.nextHuanJie = 703;
            check(data, function () {
                loadDataFor702();
                alert('您同意物资报废！');
            });
        });

        // 部门负责人不同意
        $('#bmspBHPL').click(function(){
            var data = $("#bmbaoFeiForm").parseForm();
            if (!data.baoFeiId) {
                alert('未选择审批内容');
                return;
            }
            $('#bmbaoFeiForm').attr("action", "${ctx}/wuzi/bfhqBHPL.do?url=/wuzi/bmspList.do&container=bmsp&nextHuanJie=718").attr("target","_blank").submit();
        });
        // 显示归口部门审批列表
        $('#bfxgbmspTab').click(function(){
            loadDataFor717();
        });

        $('#bmspTab').click(function(){
            loadDataFor702();
        });

        // 归口部门批量同意
        $('#bfhqPiSubmit').click(function(){
            var data = $("#baoFeiHQForm").parseForm();
            if (!data.baoFeiId) {
                alert('未选择审批内容');
                return;
            }
            data.nextHuanJie = 713;
            check(data, function () {
                loadDataFor717();
                alert('您同意物资报废！');
            });
        });

        // 归口部门批量不同意
        $('#bfhqBHPL').click(function(){
            var data = $("#baoFeiHQForm").parseForm();
            if (!data.baoFeiId) {
                alert('未选择审批内容');
                return;
            }
            $('#baoFeiHQForm').attr("action", "${ctx}/wuzi/bfhqBHPL.do?url=/wuzi/baofeidan/bfxgbmspList.do&container=bfxgbmspData&nextHuanJie=703").attr("target","_blank").submit();
        });

        // 全选与反选
        $('.table').find('thead').find('input[type="checkbox"]').click(function () {
            var _$itemBody = $(this).parents('table').find('tbody'),
                _$item = _$itemBody.find('input[type="checkbox"]');

            if ($(this).attr("checked")) {
                _$item.attr("checked", true);
                _$item.parent().addClass("checked");
            } else {
                _$item.attr("checked", false);
                _$item.parent().removeClass("checked");
            }

            var _$itemChecked = _$itemBody.find('input[type="checkbox"]:checked'),
                _leng = _$itemChecked.length,
                _$checkedText = $(this).closest('form').find('.checked-text');
            if (_leng > 0) {
                _$checkedText.html('已选中&nbsp;<span style="color:#1890ff;">' + _leng + '</span>&nbsp;条数据');
            } else {
                _$checkedText.html('');
            }
        });
        setActiveTab();
    });

    function setActiveTab() {
        var activeTab = $('.nav-tabs').find('li:first');
        activeTab.find('a').trigger('click');
        activeTab.addClass('active');
    }
    function itemCheckClick($container) {
        $container.find('input[type="checkbox"]').unbind('click').click(function () {
            var _$itemBody = $(this).parents('tbody'),
                _$itemChecked = _$itemBody.find('input[type="checkbox"]:checked'),
                _leng = _$itemChecked.length,
                _$checkedText = $(this).closest('form').find('.checked-text');

            if (_leng > 0) {
                _$checkedText.html('已选中&nbsp;<span style="color:#1890ff;">' + _leng + '</span>&nbsp;条数据');
            } else {
                _$checkedText.html('');
            }
        });
    }


    /**
     * 继续报废审批
     * @param id
     */
    function jiXuSP(id) {
        var data = {};
        data.baoFeiId = id;
        data.nextHuanJie = 717;
        check(data, function () {
            loadYiShenQingBaoFeiListData();
            alert('您同意物资报废！');
        });
    }

    /**
     * 直接报废
     * @param id
     */
    function zhiJieBF(id) {
        if (confirm('确定直接报废吗？')) {
            var data = {};
            data.baoFeiId = id;
            data.nextHuanJie = 713;
            check(data, function () {
                loadYiShenQingBaoFeiListData();
                alert('物资已直接报废！');
            });
        }
    }

    function loadYiShenQingBaoFeiListData() {
        $.ajax({
            type:"POST",
            url:"${ctx}/wuzi/gzglyspList.do",
            dataType:"html",
            success:function(data){
                $("#yiShenQingBaoFeiList_data").html(data);
            }
        });
    }

    function loadDataFor702() {
        $.ajax({
            type:"POST",
            url:"${ctx}/wuzi/bmspList.do",
            dataType:"html",
            success:function(data){
                $("#bmsp").html(data);
                itemCheckClick($("#bmsp"));
            }
        });
    }

    function loadDataFor717() {
        $.ajax({
            type:"POST",
            url:"${ctx}/wuzi/baofeidan/bfxgbmspList.do",
            dataType:"html",
            success:function(data){
                $("#bfxgbmspData").html(data);
                itemCheckClick($("#bfxgbmspData"));
            }
        });
    }

    function agreeTo703(id) {
        var data = {};
        data.baoFeiId = id;
        data.nextHuanJie = 703;
        check(data, function () {
            loadDataFor702();
            alert('您同意物资报废！');
        });
    }

    function agreeTo713(id) {
        var data = {};
        data.baoFeiId = id;
        data.nextHuanJie = 713;
        check(data, function () {
            loadDataFor717();
            alert('您同意物资报废！');
        });
    }

    function check(data, callback) {
        $.ajax({
            type:"POST",
            data: data,
            url:"${ctx}/wuzi/baofei/check.do",
            dataType:"json",
            success:function(data){
                if (data.success) {
                    if (typeof callback != 'undefined') {
                        callback();
                    }
                } else {
                    alert("操作失败，请稍后再试");
                }
            }
        });
    }

</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>